Skip to content

support "unlimited" for the Jackson stream-read constraints - #3522

Open
pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:jackson3-unlimited-read-constraints
Open

support "unlimited" for the Jackson stream-read constraints#3522
pjfanning wants to merge 1 commit into
apache:mainfrom
pjfanning:jackson3-unlimited-read-constraints

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

Review on #3515 preferred an explicit unlimited keyword over -1 as a magic number.
Auditing the configuration listed in #3513 for other -1-means-unlimited settings turned
up exactly one family: the Jackson stream-read constraints read.max-document-length and
read.max-token-count, whose comments say "-1 means unlimited" but which only accept
numbers (getLong).

Nothing else in that list qualifies: the other new settings are durations, counts with
real defaults, booleans or strings, and fork-join-executor.minimum-runnable = -1 means
"JDK-aware default" — not unlimited — so the keyword would be wrong there.
compression.max-decompressed-size already gains unlimited in #3515.

Modification

JacksonObjectMapperProvider in both serialization-jackson and
serialization-jackson3 reads unlimited as -1 for read.max-document-length and
read.max-token-count, and the reference.conf defaults are written as unlimited. A
negative number such as -1 is still accepted, so existing overrides keep working.

Both modules are changed together so the jackson3 section keeps mirroring the jackson
one, per the migration guide.

Result

max-document-length = unlimited and max-token-count = unlimited work in both
modules; the effective defaults are unchanged.

Tests

  • New support unlimited as a StreamReadConstraints value test in each module's
    JacksonFactorySpec, asserting the built StreamReadConstraints carries -1
  • The existing suites also now exercise the keyword through the changed defaults
  • sbt "serialization-jackson/testOnly org.apache.pekko.serialization.jackson.*" — 129 passed
  • sbt "serialization-jackson3/testOnly org.apache.pekko.serialization.jackson3.*" — 127 passed
  • sbt "serialization-jackson/scalafmtCheckAll" "serialization-jackson3/scalafmtCheckAll" — clean
  • MiMa left to the Check / Binary Compatibility job; the only code change is a private
    helper

References

Refs #3513, Refs #3515

Motivation:
Review on apache#3515 preferred an explicit keyword over -1 as a magic number
for unlimited. Among the configuration listed in apache#3513, the Jackson
read constraints max-document-length and max-token-count document -1 as
meaning unlimited but only accept numbers.

Modification:
JacksonObjectMapperProvider in serialization-jackson and
serialization-jackson3 reads "unlimited" as -1 for
read.max-document-length and read.max-token-count, and the
reference.conf defaults are written as `unlimited`. A negative number
such as -1 is still accepted.

Result:
`max-document-length = unlimited` and `max-token-count = unlimited`
work; the effective defaults are unchanged.

Tests:
- sbt "serialization-jackson/testOnly org.apache.pekko.serialization.jackson.*" - 129 passed
- sbt "serialization-jackson3/testOnly org.apache.pekko.serialization.jackson3.*" - 127 passed
- sbt "serialization-jackson/scalafmtCheckAll" "serialization-jackson3/scalafmtCheckAll" - clean

References:
Refs apache#3513, Refs apache#3515
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant